<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		请输入数字: <input type="text" />
		<script type="text/javascript">
			let input=document.querySelector("input")
			input.onkeypress=function(){
				console.log(`你输入的内容是${event.key},键码是${event.keyCode}`);
				//数字48-57
				//字母65-122
				//大写65-90
				//小写97-122
				if (event.keyCode<48||event.keyCode>57) {
					alert("只能输入数字")
					event.preventDefault()
				}
			}
		</script>
	</body>
</html>
